//
//  VCOfThird.m
//  08--Homework  通讯录
//
//  Created by 冀永金 on 16/7/25.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "VCOfThird.h"

@interface VCOfThird ()

@property (nonatomic, strong) UITextField *name;
@property (nonatomic, strong) UITextField *age;
@property (nonatomic, strong) UITextField *gender;
@property (nonatomic, strong) UITextField *phoneNum;
@end

@implementation VCOfThird

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 80, 40)];
    [self.view addSubview:nameLabel];
    nameLabel.text = @"姓名:";
    self.name = [[UITextField alloc]initWithFrame:CGRectMake(100, 10, 100, 40)];
    [self.view addSubview:_name];
    _name.placeholder = @"请输入姓名";
    // name.backgroundColor = [UIColor redColor];
   
    UILabel *phoneNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 80, 40)];
    [self.view addSubview:phoneNumLabel];
    phoneNumLabel.text = @"电话号码:";
    self.phoneNum = [[UITextField alloc]initWithFrame:CGRectMake(100, 60, 140, 40)];
    [self.view addSubview:_phoneNum];
    _phoneNum.placeholder =@"请输入电话号";
    // phoneNum.backgroundColor = [UIColor yellowColor];
  
    UILabel *genderLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 110, 80, 40)];
    [self.view addSubview:genderLabel];
    genderLabel.text = @"性别:";
    self.gender = [[UITextField alloc]initWithFrame:CGRectMake(100, 110, 100, 40)];
    [self.view addSubview:_gender];
    _gender.placeholder = @"请输入性别";
    //gender.backgroundColor = [UIColor blueColor];
    
    UILabel *ageLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 160, 80, 40)];
    [self.view addSubview:ageLabel];
    ageLabel.text = @"年龄";
    self.age = [[UITextField alloc]initWithFrame:CGRectMake(100, 160, 100, 40)];
    [self.view addSubview:_age];
    _age.placeholder = @"请输入年龄";
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(50, 210, 80, 40);
    [self.view addSubview:button];
    [button setTitle:@"保存" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(handleSave:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
    
    // Do any additional setup after loading the view.
}
- (void)handleSave:(UIButton *)button {
    NSMutableDictionary *mdic = [NSMutableDictionary dictionary];
    if (self.delegate &&[self.delegate respondsToSelector:@selector(saveName:)]) {
        [self.delegate saveName:mdic];
        [mdic setObject:self.name.text forKey:@"name"];
        [mdic setObject:self.gender.text forKey:@"gender"];
        [mdic setObject:self.phoneNum.text forKey:@"phoneNumber"];
        [mdic setObject:self.age.text forKey:@"age"];
        
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
